﻿
Partial Class UCMain_Track_application
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If IsNothing(Session("section")) Then
            Session.Clear()
            Response.Redirect("../Login.aspx")
        End If
        If Not IsPostBack Then
            img.Visible = False
            lblerror.Text = ""
            loadDataLogin()
        End If
    End Sub

    Sub loadDataLogin()
        Dim sql As String = ""
        sql = " select * from [user_table] where id_user =" & Session("ID_USER") & ""
        Dim dt As New Data.DataTable
        dt = clsCommand.SQL_exec(sql)
        If dt.Rows.Count > 0 Then
            TxtReqBy.Text = dt.Rows(0)("firstname").ToString & " " & dt.Rows(0)("lastname").ToString
            TxtCompReqBy.Text = dt.Rows(0)("Company").ToString & "/" & dt.Rows(0)("section").ToString
            TxtTelReqBy.Text = dt.Rows(0)("tel").ToString
        End If
    End Sub

    Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
        Try
            Dim sql As String = ""
            sql = " select * from [user_table] where id_picop='" & TxtPicopNo.Text & "' and [section]='" & Session("section") & "'"
            Dim dt As New Data.DataTable
            dt = clsCommand.SQL_exec(sql)
            If dt.Rows.Count > 0 Then
                txtNamePICOP.Text = dt.Rows(0)("firstname").ToString & " " & dt.Rows(0)("lastname").ToString
                TxtCompPicop.Text = dt.Rows(0)("Company").ToString & "/" & dt.Rows(0)("section").ToString
                TxtTelPicop.Text = dt.Rows(0)("tel").ToString
                lblIDPICop.Text = dt.Rows(0)("ID_USER")
                TxtWorkApp.Text = txtNamePICOP.Text
                TxtComWorkapp.Text = TxtCompPicop.Text
                TxtTelWorkapp.Text = TxtTelPicop.Text
            Else
                img.Visible = True
                lblerror.Text = Utility.clsAlertMsg.infoMessage(img, "I003", TxtPicopNo.Text)
            End If
        Catch ex As Exception

        End Try
    End Sub

    Protected Sub RadioButtonTrain_Vihicle_SelectedIndexChanged(sender As Object, e As EventArgs) Handles rdoTrain_Vihicle.SelectedIndexChanged
        If rdoTrain_Vihicle.SelectedIndex = 0 Then
            chkT.Visible = False
        Else
            chkT.Visible = True
        End If
    End Sub
    Protected Sub rdoTrain_Vihicle2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles rdoTrain_Vihicle2.SelectedIndexChanged
        If rdoTrain_Vihicle2.SelectedIndex = 0 Then
            chkV.Visible = False
        Else
            chkV.Visible = True
        End If
    End Sub

    Protected Sub rdoWorkLocate_SelectedIndexChanged(sender As Object, e As EventArgs) Handles rdoWorkLocate.SelectedIndexChanged
        Dim sql As String = ""
        Dim dt As New Data.DataTable
        Dim dfield As String = ""
        '1=station , 2= signal
        If rdoWorkLocate.SelectedValue = "1" Then
            sql = " select id,[station]+' '+ [area] as stArea from [station] "
            dt = clsCommand.SQL_exec(sql)
            dfield = "stArea"
        ElseIf rdoWorkLocate.SelectedValue = "2" Then
            sql = " select id, signal from signal where 1=1 "
            dt = clsCommand.SQL_exec(sql)
            dfield = "signal"
        End If
        
        DDlWorkLocate_From.DataSource = dt
        DDlWorkLocate_From.DataTextField = dfield
        DDlWorkLocate_From.DataValueField = dfield
        DDlWorkLocate_From.DataBind()

        DDlWorkLocate_To.DataSource = dt
        DDlWorkLocate_To.DataTextField = dfield
        DDlWorkLocate_To.DataValueField = dfield
        DDlWorkLocate_To.DataBind()
    End Sub

  


    Protected Sub RadioButtonEnergize_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadioButtonEnergize.SelectedIndexChanged
        If RadioButtonEnergize.SelectedIndex = 0 Then
            CheckBoxE_1_6.Visible = False
            CheckBoxW_1_6.Visible = False
        Else
            CheckBoxE_1_6.Visible = True
            CheckBoxW_1_6.Visible = True
        End If
    End Sub

    Function checkBeforeSave() As Boolean
        Dim err As Boolean = True

        Return err
    End Function

    Protected Sub Button_Submit_Click(sender As Object, e As EventArgs) Handles Button_Submit.Click
        Try
            If checkBeforeSave() Then

            End If
        Catch ex As Exception

        End Try
    End Sub

End Class
